package cn.edu.zjgsu.ito.service;

import java.util.List;
import cn.edu.zjgsu.ito.model.StudentModel;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class StuScoreService  extends Service{
	/*
	 * 张虎涛
	 * 2016/06/01
	 */
	public List<Record> MyScore(String passportNo) {
		try {
			
			List<Record> record=Db.find(StudentModel.dao.selectAllStuScooSql, passportNo);
			return record;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}

	}

	public List<Record> searchScore(String passportNo, String term) {
		try {

			List<Record> record = Db.find(StudentModel.dao.selectStuScooSql,passportNo,term);
			return record;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public List<Record> selectStuGrade(String id) {
		try {
			List<Record> list=Db.find(StudentModel.dao.selectStuGradeSql,id);
			
			return list;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}

	}
	
	public List<Record> checkStuGrade(int id,int status) {
		try {
			List<Record> list=Db.find("select * from student_grade where uuid=? and gradeStatus=?",id,status);

			return list;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
        }
	}
    
    public int getGradeStatus(String uuid){
        Record record=Db.findFirst("select * from student_grade where uuid=?",uuid);
        if(record==null){
            return 0;
        }else{
            int status=record.getInt("gradeStatus");    
            return status;
        }   
    }
    
    public boolean updateScoreGradeStatus(String uuid){
        System.out.println("2222222222222222222222222222222222222222222222222222:"+uuid);
        int i=0;
         
        int record=Db.update("update student_grade set gradeStatus=? where uuid=?",i,uuid);
        if(record<=0){
            System.out.println("学生成绩，更新失败！！！！！！！！！！！！！！，未录入成绩");
            return false;
        }else{
           return true;
        }   
    }

}
